package org.yaac.shared.egql;

import java.io.Serializable;

/**
 * @author Max Zhu (thebbsky@gmail.com)
 *
 */
public class Request implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String command;
	
	private int batchSize;
	
	private int maxResult;

	/**
	 * for GWT use
	 */
	@SuppressWarnings("unused")
	private Request() {}
	
	public Request(String command, int batchSize, int maxResult) {
		super();
		this.command = command;
		this.batchSize = batchSize;
		this.maxResult = maxResult;
	}

	public String getCommand() {
		return command;
	}

	public int getBatchSize() {
		return batchSize;
	}

	public int getMaxResult() {
		return maxResult;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + batchSize;
		result = prime * result + ((command == null) ? 0 : command.hashCode());
		result = prime * result + maxResult;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Request other = (Request) obj;
		if (batchSize != other.batchSize)
			return false;
		if (command == null) {
			if (other.command != null)
				return false;
		} else if (!command.equals(other.command))
			return false;
		if (maxResult != other.maxResult)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "QueryRequest [command=" + command + ", batchSize=" + batchSize + ", maxResult="
				+ maxResult + "]";
	}	
}